﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class ResourcePoolTest
{
    private static ResourcePool pool;

    public static void Main()
    {
        pool = new ResourcePool();
        Method1();
        Console.WriteLine(pool);
        Method2();
    }

    public static void Method1()
    {
        pool.InsureCapacity(3);
        Console.WriteLine(pool);
        Resource[] resources = new Resource[3];
        for (int i = 0; i < 3; i++)
        {
            resources[i] = pool.GetResource();
            resources[i].Info = "main" + i;
        }
        Console.WriteLine(pool);
        foreach (Resource res in resources)
        {
            res.Dispose();
        }
   //     GC.Collect();

    }

    public static void Method2()
    {
        Console.WriteLine("method2");
        Console.WriteLine(pool);
        Resource r = pool.GetResource();
        Console.WriteLine(pool);
        Console.WriteLine(r.Info);
    }
}